import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

service = Service(executable_path='D:\\chromedriver.exe')
driver = webdriver.Chrome(service=service)
driver.maximize_window()
driver.get("https://www.cninfo.com.cn/new/commonUrl/pageOfSearch?url=disclosure/list/search")

while True:

	items = driver.find_elements(By.XPATH, '//table[@class="el-table__body"]//tr')
	for item in items:
		# title = item.find_element(By.XPATH, './/td[@class="el-table_1_column_3  "]//a')

		title = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, './/td[@class="el-table_1_column_3  "]//a')))

		# 点击元素
		title.click()
		# 切换到新窗口
		driver.switch_to.window(driver.window_handles[-1])



		time.sleep(1)
		down_load_btn = driver.find_element(By.CLASS_NAME, 'icongonggaoxiazai')
		down_load_btn.click()

		time.sleep(1)

		driver.close()

		driver.switch_to.window(driver.window_handles[0])

	try:
		next_page_btn = driver.find_element(By.CLASS_NAME, 'btn-next')
		next_page_btn.click()
		print(f"翻页")

		driver.execute_script("window.scroll(0, 0)")
		time.sleep(1)
	except:
		break





input()
driver.quit()